// 批量创建数据

const batchCreated = {
  // this.$store.state.batchCreated.account_id
  state: { 
    campaign:null, // account_id:广告组数据  campaign_id:账号数据 landing_type:推广目的
    ad:null,
    creative:null,  //广告创意数据
    creativeGroups:[], // 创意组素材

    call_to_action:[],  //卡片 行动号召

    // 回显储存数据格式
    echoView:{
      accountForm:{},  // 广告组账号
      campaignForm:{}, // 广告组
      adForm:{},   // 广告计划
      creativeForm:{},  // 创意字段
      creativeGroups:[]  // 创意组
    }
  },

  // this.$store.commit( 'batchCreated/SET_ACCOUNT_ID', account_id );
  mutations: {
    SET_CAMPAIGNS: (state, campaigns) => {
      state.campaign = null
      state.campaign = campaigns
    },
    SET_AD: (state, ad) => {
      state.ad = null
      state.ad = ad
    },
    SET_CREATIVE_GROUPS: (state, creativeGroups) => {
      state.creativeGroups = null
      state.creativeGroups = creativeGroups
    },
    SET_CREATIVE: (state, creative) => {
      state.creative = null
      state.creative = creative
    },
    SET_CALL_TO_ACTION: (state, action) => {
      state.call_to_action = action
    },
    // 回显储存数据
    SET_ECHO_VIEW_ACCOUNT_ID:(state, accountForm)=>{
      console.info(accountForm,'accountForm11')
      state.accountForm = {}
      state.echoView.accountForm = accountForm
    },
    SET_ECHO_VIEW_CAMPAIGN:(state, campaignForm)=>{
      state.campaignForm = {}
      state.echoView.campaignForm = campaignForm
    },
    SET_AD_FORM:(state, adForm)=>{
      state.adForm = {}
      state.echoView.adForm = adForm
    },
    SET_CREATIVE_FORM:(state, creativeForm)=>{
      state.creativeForm = {}
      state.echoView.creativeForm = creativeForm
    },
    SET_CREATIVE_GROUPS_VIEW:(state, creativeGroups)=>{
      state.echoView.creativeGroups = []
      state.echoView.creativeGroups = creativeGroups
    },
  },

  // store.dispatch('batchCreated/xxx')
  actions: {
    // 可以异步操作 比如请求接口  再去修改mutations
    // xxx({ commit,state }){
    //   return new Promise((resolve, reject) => {
    //     commit('mutations', data )
    //     resolve(xx)
    //   }).catch((err)=>{reject(err)})
    // }
  }
}

export default batchCreated

